package com.doublethread.easymart.modules.order.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 发货状态枚举
 */
@Getter
@AllArgsConstructor
public enum DeliveryStatus {

    /**
     * 未发货
     */
    NOT_DELIVERED(0, "未发货"),

    /**
     * 已发货
     */
    DELIVERED(1, "已发货"),

    /**
     * 已收货
     */
    RECEIVED(2, "已收货");

    /**
     * 状态码
     */
    private final Integer code;

    /**
     * 状态描述
     */
    private final String description;

    /**
     * 根据状态码获取枚举
     */
    public static DeliveryStatus getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DeliveryStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}
